package com.cloud.test03;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

/**
 * 字节流相应乱码问题    OutputStream
 * 解决方案同 PrintWrite
 *
 * //同时设置客户端和服务端
 *  response.setContentType("text/html;charset=UTF-8");
 * @author DELL
 */
@WebServlet(value = {"/ReTest03","/retest03"})
public class ResponseTest03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        OutputStream out = response.getOutputStream();
        out.write("<h1>你好</h1>".getBytes(StandardCharsets.UTF_8));
    }
}
